#pragma once
#include "vocoder.h"
//#include "GFFT.h"
#include "Sample.h"
#include "FFTWrapper.h"
#include <vector>
#include <map>

class SoundBank;
class WaveFormProvider;

/*
Implementation of Carrier that does FFT on incoming sample, and uses a chain of FFTProcessors to create its carrier signal
*/
class ResynthCarrier :
	public Carrier
{
public:
	ResynthCarrier(unsigned int samplingRate, SoundBank* soundBank);
	~ResynthCarrier(void);

	//carrier methods
	void SetFrequencyProvider(FrequencyProvider* frequencyProvider){}
	void SetVocoderListener(VocoderListener* vocoderListener);
	short* CreateCarrierSample(Settings* settings, short* modulatorSample, unsigned int length, std::vector<SampleMarker>* markers);

	//chain of FFTProcessors, called in sequence in CreateCarrierSample
	std::vector<FFTProcessor*> fftProcessors;

private:
	unsigned int samplingRate;
	Sample mySample;
	std::vector<double> fftSample;

	/*
	GFFT<256, 7> fft256;
	GFFT<512, 8> fft512; 
	GFFT<1024, 9> fft1024;
	GFFT<2048, 10> fft2048;
	GFFT<4096, 11> fft4096;
	*/
	//FFTWrapper fft;
	FFT fft;
	SoundBank* soundBank;
	std::map<int, WaveFormProvider*> waveFormProviders;
	VocoderListener* vocoderListener;

	WaveFormProvider* GetWaveFormProvider(int frequency);
	void SineWaveFromComplexFFT(Complex* complex, unsigned int length);
	short* CreateCarrierSampleWithProcessors();
	short* CreateCarrierSampleWithSineWaves();
};
